<?php

function getSubMenuList($headCategory) {// tar headcategory i getpaintings för att avgöra vilka undermenyer som gäller
             include '../phpFunctions/databaseConnect.php';
             $result = mysql_query("select subCategoryName from subCategory, category
                                    where subCategory.parentCategoryID = category.category_id
                                    and category.categoryName = '$headCategory'" );
             $i = 0;
             while($row = mysql_fetch_assoc($result))  {
                 $subCategory = $row["subCategoryName"];
                 $subCategoryArray[$i] = $subCategory;
                 ++$i;
             }




             return $subCategoryArray;


}


?>



<center>
<ul id="subMenu">

<?php
if ($location != NULL){
    $locationUrl ="&location=$location";
}
$priceSort=$_GET['priceSort'];
if ($priceSort != NULL){
    $sortUrl ="&priceSort=$priceSort";
}
$subCategoryArray = getSubMenuList($headCategory);
$url = '../Bildgalleri/getPaintings.php';
$i = 0;
print "<br>";
while ($i < count($subCategoryArray)) {

echo "
<li><a href='", $url, '?subCategory=' . $subCategoryArray[$i] . '&headCategory=' . $headCategory . $locationUrl . $sortUrl."'>$subCategoryArray[$i]</a></li>";
++$i;
}
?>


</ul>
</center>

